

<template>
  <div style="padding: 20px">
    <el-row>
      <el-col :span="8">
        <div style="display: flex;align-items: center;margin-bottom: 10px">
          <span style="flex: 0 0 auto;margin-right: 10px">标题:</span>
          <el-input v-model="queryParam.title" clearable></el-input>
        </div>
      </el-col>
      <el-col :span="8">
        <div style="display: flex;align-items: center;margin-bottom: 10px;">
          <el-button type="primary" size="small" style="margin-left: 10px" @click="handlerSearch">查询</el-button>
          <el-button type="primary" size="small" @click="handlerAdd">添加</el-button>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <el-table

          :data="tableData"
          style="width: 100%">
          <el-table-column
            show-overflow-tooltip
            label="ID"
            width="80"
          >
            <template #default="{row}">
              {{ row.id }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="标题"
          >
            <template #default="{row}">
             <div @click="handlerToDetail(row)"> {{ row.title }}</div>
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="子标题"
          >
            <template #default="{row}">
              {{ row.title }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="创建时间"
          >
            <template #default="{row}">
              {{ row.createdTime }}
            </template>
          </el-table-column>
          <el-table-column
            show-overflow-tooltip
            label="更新时间"
          >
            <template #default="{row}">
              {{ row.createdTime }}
            </template>
          </el-table-column>
          <el-table-column label="操作" fixed="right" width="150">
            <template #default="{row}">
              <el-button type="danger" size="mini" @click="handlerDel(row)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
      <el-col :span="24" class="mt-2 flex justify-center">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryParam.pageNum"
          :page-sizes="[5,10,20]"
          :page-size="queryParam.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>
<script>
import api from '@/api/users'

export default {
  name: "index",
  data() {
    return {
      total: 0,
      tableData: [],
      queryParam: {
        pageSize: 5,
        pageNum: 1
      }
    }
  },
  mounted() {
    this.fetchData()
  },
  methods: {
    handlerAdd(){
      this.$router.push("/apply/xing_zheng_gui_fan/add")
    },
    handlerSearch() {
      this.queryParam.pageNum = 1
      this.fetchData()
    },
    handlerDel(row) {
      api.xing_zheng_gui_fan_del(row.id).then(() => {
        this.$notify.success({
          title: '提示',
          message: '操作成功'
        })
        this.fetchData()
      })
    },
    handlerToDetail(row) {
      this.$router.push(`/apply/xing_zheng_gui_fan/detail?id=${row.id}`)
    },
    async fetchData() {
      let {data} = await api.xing_zheng_gui_fan_list(this.queryParam);
      console.log('>>>>>>>>>>>data', data)
      this.tableData = data.records;
      this.total = data.total
    },
    handleCurrentChange(size) {
      this.queryParam.pageNum = size
      this.fetchData()
    },
    handleSizeChange(size) {
      this.queryParam.pageSize = size
      this.fetchData()
    }
  }
}
</script>
<style scoped>

</style>
